#pragma once
#include <iostream>
#include <string>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
class Inetaddr
{
private:
    uint16_t _port;
    std::string _ip;
    struct sockaddr_in _addr;

public:
    Inetaddr(struct sockaddr_in addr) : _addr(addr), _port(ntohs(addr.sin_port)), _ip(inet_ntoa(addr.sin_addr))
    {
    }
    uint16_t port()
    {
        return _port;
    }
    std::string ip()
    {
        return _ip;
    }
    struct sockaddr_in& Netaddr()
    {
        return _addr;
    }
    bool operator!=(Inetaddr& peer)
    {
        return !(this->operator==(peer));
    }
    bool operator==(Inetaddr& peer)
    {
        return (_ip==peer.ip()&&_port==peer.port());
    }
    ~Inetaddr()
    {
    }
};